import type {ListResult, UserFilter, UserInfo} from "@/api/types";
import request from "@/api/request";

const me = ():Promise<UserInfo> => {

    /*const response = await instance.post('/login', { username, password });
    const { accessToken, refreshToken } = response; // 假设响应包含 token*/

    return request.get("/users/me");
};

const list = (filter: UserFilter): Promise<ListResult<UserInfo>> => {
    return request.get("/users/list", {
        params: filter,
        removeCache: true
    });
};

const create = (userCreateRequest: UserCreateRequest): Promise<UserType> => {
    return request.post("/users/add", userCreateRequest);
};

// Todo:
const edit = (
    id: string,
    userEditRequest: UserCreateRequest
): Promise<UserType> => {
    return request.post(`/users/${id}`, userEditRequest);
};

export default {
    me,
    list,
    create,
    edit,
};